﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.supplyPlan
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtpurchaseid.Text.Trim().Length==0)
			{
				strErr+="purchaseid不能为空！\\n";	
			}
			if(this.txtproid.Text.Trim().Length==0)
			{
				strErr+="proid不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtprojectId.Text))
			{
				strErr+="projectId格式错误！\\n";	
			}
			if(this.txtbidid.Text.Trim().Length==0)
			{
				strErr+="bidid不能为空！\\n";	
			}
			if(this.txtusework.Text.Trim().Length==0)
			{
				strErr+="usework不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtsupplyDate.Text))
			{
				strErr+="supplyDate格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtmid.Text))
			{
				strErr+="mid格式错误！\\n";	
			}
			if(this.txttechnicalDataStatus.Text.Trim().Length==0)
			{
				strErr+="technicalDataStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txttechnicalDataStatusDate.Text))
			{
				strErr+="technicalDataStatusDate格式错误！\\n";	
			}
			if(this.txtsupplyDateStatus.Text.Trim().Length==0)
			{
				strErr+="supplyDateStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtsupplyDateStatusDate.Text))
			{
				strErr+="supplyDateStatusDate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtarrivalCount.Text))
			{
				strErr+="arrivalCount格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtcontractdate.Text))
			{
				strErr+="contractdate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtfristCheckedCount.Text))
			{
				strErr+="fristCheckedCount格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtinstoreCount.Text))
			{
				strErr+="instoreCount格式错误！\\n";	
			}
			if(this.txtarrivalEvaluationStatus.Text.Trim().Length==0)
			{
				strErr+="arrivalEvaluationStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtarrivalEvaluationStatusDate.Text))
			{
				strErr+="arrivalEvaluationStatusDate格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtoutstoreCount.Text))
			{
				strErr+="outstoreCount格式错误！\\n";	
			}
			if(this.txtinstallationStatus.Text.Trim().Length==0)
			{
				strErr+="installationStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtinstallationStatusDate.Text))
			{
				strErr+="installationStatusDate格式错误！\\n";	
			}
			if(this.txtputOperationStatus.Text.Trim().Length==0)
			{
				strErr+="putOperationStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtputOperationStatusDate.Text))
			{
				strErr+="putOperationStatusDate格式错误！\\n";	
			}
			if(this.txtputOperationEvaluationStaus.Text.Trim().Length==0)
			{
				strErr+="putOperationEvaluationStaus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtputOperationEvaluationStausDate.Text))
			{
				strErr+="putOperationEvaluationStausDate格式错误！\\n";	
			}
			if(this.txtwarrantyStatus.Text.Trim().Length==0)
			{
				strErr+="warrantyStatus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtwarrantyStatusDate.Text))
			{
				strErr+="warrantyStatusDate格式错误！\\n";	
			}
			if(this.txtwinBid.Text.Trim().Length==0)
			{
				strErr+="winBid不能为空！\\n";	
			}
			if(this.txtwarrantyEvaluationStaus.Text.Trim().Length==0)
			{
				strErr+="warrantyEvaluationStaus不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtwarrantyEvaluationStausDate.Text))
			{
				strErr+="warrantyEvaluationStausDate格式错误！\\n";	
			}
			if(this.txtsourceProid.Text.Trim().Length==0)
			{
				strErr+="sourceProid不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtsourceProjectId.Text))
			{
				strErr+="sourceProjectId格式错误！\\n";	
			}
			if(this.txtsourceProjectName.Text.Trim().Length==0)
			{
				strErr+="sourceProjectName不能为空！\\n";	
			}
			if(this.txtequipmentManage.Text.Trim().Length==0)
			{
				strErr+="equipmentManage不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtsid.Text))
			{
				strErr+="sid格式错误！\\n";	
			}
			if(this.txtconfirmDateWarn.Text.Trim().Length==0)
			{
				strErr+="confirmDateWarn不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtwasteCount.Text))
			{
				strErr+="wasteCount格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtrealSupplyDate.Text))
			{
				strErr+="realSupplyDate格式错误！\\n";	
			}
			if(this.txtwarrantyTime.Text.Trim().Length==0)
			{
				strErr+="warrantyTime不能为空！\\n";	
			}
			if(this.txtsettlementTimeWarn.Text.Trim().Length==0)
			{
				strErr+="settlementTimeWarn不能为空！\\n";	
			}
			if(this.txtcoordinate.Text.Trim().Length==0)
			{
				strErr+="coordinate不能为空！\\n";	
			}
			if(this.txtdeviceproductionstate.Text.Trim().Length==0)
			{
				strErr+="deviceproductionstate不能为空！\\n";	
			}
			if(this.txtremark.Text.Trim().Length==0)
			{
				strErr+="remark不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtuser_id.Text))
			{
				strErr+="user_id格式错误！\\n";	
			}
			if(this.txtsupplyPlanType.Text.Trim().Length==0)
			{
				strErr+="supplyPlanType不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string purchaseid=this.txtpurchaseid.Text;
			string proid=this.txtproid.Text;
			int projectId=int.Parse(this.txtprojectId.Text);
			string bidid=this.txtbidid.Text;
			string usework=this.txtusework.Text;
			DateTime supplyDate=DateTime.Parse(this.txtsupplyDate.Text);
			int mid=int.Parse(this.txtmid.Text);
			string technicalDataStatus=this.txttechnicalDataStatus.Text;
			DateTime technicalDataStatusDate=DateTime.Parse(this.txttechnicalDataStatusDate.Text);
			string supplyDateStatus=this.txtsupplyDateStatus.Text;
			DateTime supplyDateStatusDate=DateTime.Parse(this.txtsupplyDateStatusDate.Text);
			decimal arrivalCount=decimal.Parse(this.txtarrivalCount.Text);
			DateTime contractdate=DateTime.Parse(this.txtcontractdate.Text);
			decimal fristCheckedCount=decimal.Parse(this.txtfristCheckedCount.Text);
			decimal instoreCount=decimal.Parse(this.txtinstoreCount.Text);
			string arrivalEvaluationStatus=this.txtarrivalEvaluationStatus.Text;
			DateTime arrivalEvaluationStatusDate=DateTime.Parse(this.txtarrivalEvaluationStatusDate.Text);
			decimal outstoreCount=decimal.Parse(this.txtoutstoreCount.Text);
			string installationStatus=this.txtinstallationStatus.Text;
			DateTime installationStatusDate=DateTime.Parse(this.txtinstallationStatusDate.Text);
			string putOperationStatus=this.txtputOperationStatus.Text;
			DateTime putOperationStatusDate=DateTime.Parse(this.txtputOperationStatusDate.Text);
			string putOperationEvaluationStaus=this.txtputOperationEvaluationStaus.Text;
			DateTime putOperationEvaluationStausDate=DateTime.Parse(this.txtputOperationEvaluationStausDate.Text);
			string warrantyStatus=this.txtwarrantyStatus.Text;
			DateTime warrantyStatusDate=DateTime.Parse(this.txtwarrantyStatusDate.Text);
			string winBid=this.txtwinBid.Text;
			string warrantyEvaluationStaus=this.txtwarrantyEvaluationStaus.Text;
			DateTime warrantyEvaluationStausDate=DateTime.Parse(this.txtwarrantyEvaluationStausDate.Text);
			string sourceProid=this.txtsourceProid.Text;
			int sourceProjectId=int.Parse(this.txtsourceProjectId.Text);
			string sourceProjectName=this.txtsourceProjectName.Text;
			string equipmentManage=this.txtequipmentManage.Text;
			int sid=int.Parse(this.txtsid.Text);
			string confirmDateWarn=this.txtconfirmDateWarn.Text;
			decimal wasteCount=decimal.Parse(this.txtwasteCount.Text);
			DateTime realSupplyDate=DateTime.Parse(this.txtrealSupplyDate.Text);
			string warrantyTime=this.txtwarrantyTime.Text;
			string settlementTimeWarn=this.txtsettlementTimeWarn.Text;
			string coordinate=this.txtcoordinate.Text;
			string deviceproductionstate=this.txtdeviceproductionstate.Text;
			string remark=this.txtremark.Text;
			int user_id=int.Parse(this.txtuser_id.Text);
			string supplyPlanType=this.txtsupplyPlanType.Text;

			Maticsoft.Model.supplyPlan model=new Maticsoft.Model.supplyPlan();
			model.purchaseid=purchaseid;
			model.proid=proid;
			model.projectId=projectId;
			model.bidid=bidid;
			model.usework=usework;
			model.supplyDate=supplyDate;
			model.mid=mid;
			model.technicalDataStatus=technicalDataStatus;
			model.technicalDataStatusDate=technicalDataStatusDate;
			model.supplyDateStatus=supplyDateStatus;
			model.supplyDateStatusDate=supplyDateStatusDate;
			model.arrivalCount=arrivalCount;
			model.contractdate=contractdate;
			model.fristCheckedCount=fristCheckedCount;
			model.instoreCount=instoreCount;
			model.arrivalEvaluationStatus=arrivalEvaluationStatus;
			model.arrivalEvaluationStatusDate=arrivalEvaluationStatusDate;
			model.outstoreCount=outstoreCount;
			model.installationStatus=installationStatus;
			model.installationStatusDate=installationStatusDate;
			model.putOperationStatus=putOperationStatus;
			model.putOperationStatusDate=putOperationStatusDate;
			model.putOperationEvaluationStaus=putOperationEvaluationStaus;
			model.putOperationEvaluationStausDate=putOperationEvaluationStausDate;
			model.warrantyStatus=warrantyStatus;
			model.warrantyStatusDate=warrantyStatusDate;
			model.winBid=winBid;
			model.warrantyEvaluationStaus=warrantyEvaluationStaus;
			model.warrantyEvaluationStausDate=warrantyEvaluationStausDate;
			model.sourceProid=sourceProid;
			model.sourceProjectId=sourceProjectId;
			model.sourceProjectName=sourceProjectName;
			model.equipmentManage=equipmentManage;
			model.sid=sid;
			model.confirmDateWarn=confirmDateWarn;
			model.wasteCount=wasteCount;
			model.realSupplyDate=realSupplyDate;
			model.warrantyTime=warrantyTime;
			model.settlementTimeWarn=settlementTimeWarn;
			model.coordinate=coordinate;
			model.deviceproductionstate=deviceproductionstate;
			model.remark=remark;
			model.user_id=user_id;
			model.supplyPlanType=supplyPlanType;

			Maticsoft.BLL.supplyPlan bll=new Maticsoft.BLL.supplyPlan();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
